<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
var flag=false;
	$(function() {
		$("#updateMovie").click(function() {
			if(confirm("수정하시겠습니까?")==false){
				return false;
			}else{
				if($(":input[name=title]").val()==""){
					alert("제목을 입력하세요!");
					return;
				}else if($("#directorSelect").val()==0){
					alert("감독을 선택하세요!");
					return;
				}else if($(":input[name=story]").val()==""){
					alert("스토리를 입력하세요!");
					return;
				}				
				$(":input[name=genre]").each(function(index,data){
					if(data.checked){
						flag=true;
						return;
					}
				});
				if(flag==false){
					alert("장르를 선택하세요!");
					return;
				}
				$("#movieUpdateForm").submit();
			}			
		});
	});//ready
</script>
<h3>영화 - 수정</h3>
<hr align="left" width="150">
<center>
<form id="movieUpdateForm" action="${initParam.root }admin/updateMovie.do" enctype="multipart/form-data" method="post">
<input type="hidden" name="movieNo" value="${requestScope.updateMap.movieVO.movieNo }">
<input type="hidden" name="posterPath" value="${requestScope.updateMap.movieVO.posterPath }">
<table class="movieWrite">
	<tbody>
		<tr>
			<td>영화제목</td><td align="left"><input type="text" name="title" size="20" value="${requestScope.updateMap.movieVO.title }"></td>
		</tr>
		<tr>
			<td>감독이름</td>
			<td align="left" colspan="3">
				<select class="select" name="directorNo" id="directorSelect">
					<option value="0">--감독--</option>
					<c:forEach items="${requestScope.updateMap.directorList }" var="data">
						<option value="${data.directorNo }">${data.name }</option>
					</c:forEach>	
				</select>
			</td>
		</tr>
		<tr>
			<td>장르</td>
			<td align="center">
				<input type="radio" name="genre" value="액션/스릴러">액션/스릴러
				<input type="radio" name="genre" value="SF">SF
				<input type="radio" name="genre" value="드라마">드라마
				<input type="radio" name="genre" value="코미디">코미디
				<input type="radio" name="genre" value="애니메이션">애니메이션
			</td>
		</tr>
		<tr>
			<td>스토리</td><td align="left"><pre><textarea cols="60" rows="10" name="story" id="content" style="resize:none;">${requestScope.updateMap.movieVO.story }</textarea></pre></td>
		</tr>
		<tr>
			<td>현재 포스터</td><td><img src="${initParam.root }${requestScope.updateMap.movieVO.posterPath }" width="150px" height="200px"></td>
		</tr>
		<tr>
			<td>포스터 변경</td><td><input type="file" name="posterFile" value="${requestScope.updateMap.movieVO.posterPath }"></td>
		</tr>
		<tr>
			<td>예고편 변경</td><td><input type="text" name="trailerPath" value="${requestScope.updateMap.movieVO.trailerPath }"></td>
		</tr>
		<tr>
			<td colspan="4" align="center">
				<img id="updateMovie" src="${initParam.root}/img/modify_btn.jpg">
			</td>
		</tr>
	</tbody>
</table>
</form>
</center>